package com.baichang.taoshunda.utils;

import com.baichang.framework.Constant;
import com.baichang.framework.utils.CodeUtils;
import com.baichang.framework.utils.RedisUtil;
import com.baichang.sms.utils.SMSUtils;

public class MsgUtils {

    /**
     * 获取验证码
     *
     * @param phone
     * @param msgCodeTemplate
     * @return
     */
    public static boolean sendMsg(String phone, String msgCodeTemplate) {
        //1.获取随机数
        String code = CodeUtils.getCode6();
        //2.将获取到的随机数放到redis下
        String redisKey = Constant.SESSION_CODE_KEY + phone;
        Integer number = 5;
        RedisUtil.setex(redisKey, code, number * 60);
        //3.调用云通讯发送验证码
        return SMSUtils.sendMsg(phone, msgCodeTemplate, code, String.valueOf(number));
    }

}
